/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package stackCalc;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 *
 * @author signal
 */
public class Main {
	
	public static void main(String[] args)
	{
		Calculator calc = null;
		try {
			calc = new Calculator("/home/signal/java/calcCommand", System.out);
			calc.start(new FileInputStream(args[1]));
		} catch(FileNotFoundException fnfe) {
			System.err.println("Can't find file. Write commands to console.");
			try {
				calc.start(System.in);
			} catch(IOException ioe) {
				System.err.println("Error with print to output.");
			}
		} catch(IndexOutOfBoundsException ioobe) {
			try {
				calc.start(System.in);
			} catch(IOException ioe) {
				System.err.println("Error with print to output.");
			}
		} catch(IOException ioe) {
			System.err.println("Error with print to output.");
		}
		/*try {
			calc = new Calculator("/home/signal/java/calcCommand", System.out);
			calc.start(new ByteArrayInputStream("DEFINE a 4\nPUSH a\nSQRT\nPRINT\n".getBytes()));
		} catch (IOException ioe) {
			ioe.printStackTrace(System.err);
		}*/
	}
	
}
